﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using StockManagement.Helper;
using StockManagement.ViewModels;
using System.Data;


namespace StockManagement.Model
{
    public class Product
    {
        public Guid ProductID { get; private set; }
        public string Name { get; set; }
        public EnumMaterialType ProductType { get; set; }
        public string ProductCode { get; set; }
        public ProductMaterialList MaterialsQuantity { get; set; }
        public string Purchaser { get; set; }
        public DateTime Date { get; set; }
        public string Consumer { get; set; }
        public ProductStatus Status { get; set; }

        public Product()
        {
            ProductID = Guid.NewGuid();
            Name = string.Empty;
            ProductCode = string.Empty;
            MaterialsQuantity = new ProductMaterialList();
            Status = ProductStatus.Defined;
            Purchaser = string.Empty;
            Consumer = string.Empty;
            ProductType = EnumMaterialType.Trading;
        }

        public Product(DataRow row)
        {
            ProductID = (Guid)row["ProductID"];
            Name = row["ProductName"].ToString();
            ProductType = (EnumMaterialType)Enum.ToObject(typeof(EnumMaterialType), int.Parse(row["Type"].ToString()));
            ProductCode = row["ProductCode"].ToString();
          //  Consumer = row["Consumer"].ToString();
            Date = (DateTime)row["Date"];
            Status = (ProductStatus)Enum.ToObject(typeof(ProductStatus), int.Parse(row["Status"].ToString()));
            Purchaser = row["Purchaser"].ToString();
            MaterialsQuantity = new ProductMaterialList();
        }
    }
}
